package china.song314.testcode;

import java.util.ArrayList;

public class Tree {

	
	static ArrayList<String> result;
	
	public static void main(String[] args) {
		result = new ArrayList<String>();
		get("123456", "123", true);
		for (String msg : result) {
			print(msg);
		}
		print("size = " + result.size());
	}
	
	public static void get(String number, String condition, boolean falg){
		if (condition.length() < number.length()) {
			String sub = number.substring(condition.length());
			String cdm = condition + sub;
			String new_cd_f = cdm.substring(0, condition.length() + 1);
//			print("cdm = " + cdm + ", new_cd_f = " + new_cd_f + ", index = " + index);
			get(cdm, new_cd_f, true);
			
			String mcd = sub + condition;
			String new_cd_b = mcd.substring(sub.length() - 1);
//			print("mcd = " + mcd + ", new_cd_b = " + new_cd_b + ", index = " + index);
			get(mcd, new_cd_b, false);
		} else {
			result.add(number);
		}

	}
	
	private static void print(String msg) {
		System.out.println(msg);
	}
}
